package com.sun.user.controller;


import com.sun.common.model.UserModel;
import com.sun.common.result.SupportResult;
import com.sun.common.service.UserService;
import com.sun.common.util.SequenceGenerator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/user")
public class UserController {


    private static SequenceGenerator sequenceGenerator = new SequenceGenerator();

    @Autowired
    private UserService userService;

    @PostMapping("/getByName")
    public SupportResult getByName(@RequestBody UserModel userModelParam){
        UserModel user=userService.lambdaQuery().eq(UserModel::getAccount,userModelParam.getAccount()).one();
        SupportResult rs=new SupportResult();
        rs.setData(user);
        return rs;
    }


    @RequestMapping(value = "/userSelect", method = RequestMethod.POST)
    public SupportResult userSelect() {
        List<UserModel> list = userService.lambdaQuery().list();
        SupportResult rs=new SupportResult(list);
        return rs;
    }

}
